home *** CD-ROM | disk | FTP | other *** search
/ Macwelt 1 / Macwelt DVD 1.toast / Web-Publishing / HTML-Editoren / Alpha ƒ / Tcl / Modes / adaMode.tcl next >
Encoding:
Text File  |  2001-01-04  |  4.1 KB  |  115 lines

  1.  
  2. alpha::mode Ada 1.0.3 dummyAda {*.ada *.ads *.adb *.ADS *.ADB *_.a *.a } {
  3.     electricBraces electricSemicolon electricTab
  4. } {} help {
  5.     The programming language Ada is named after Lady Ada Lovelace,
  6.     daughter of famed poet Lord Byron and assistant to mathematician
  7.     Charles Babbage, who invented the Analytical Machine.  Lady Ada is
  8.     often considered to be the world's first programmer.
  9.  
  10.     A descendent of Pascal, Ada is object-oriented, and offers
  11.     interfaces to the languages C, FORTRAN and COBOL. For more
  12.     information about Ada, see <http://www.adahome.com>.
  13.  
  14.     Ada Mode provides keyword coloring and procedure marking with the
  15.     Marks Menu.  Alpha includes an "Ada Example.ada" syntax file that
  16.     demonstrates the mode.  In Alpha's Ada mode, The key-binding F9
  17.     will switch between the Ada spec & body, assuming they're in the
  18.     same directory and use either GNAT or VAX Ada naming conventions.
  19.     Other conventions can be supported fairly easily.
  20. }
  21.  
  22. #===============================================================================
  23. # From Raymond Waldrop <rwaldrop@cs.tamu.edu>
  24. #===============================================================================
  25.  
  26. newPref v leftFillColumn {3} Ada
  27. newPref v prefixString {-- } Ada 
  28. newPref v wordBreak {[a-zA-Z0-9_]+} Ada
  29. newPref f wordWrap {0} Ada
  30. newPref v funcExpr {^[ \t]*(procedure|function)[ \t]+([A-Za-z][A-Za-z0-9_]*)} Ada
  31. newPref v parseExpr {^[ \t]*[^ \t]+[ \t]+([A-Za-z][A-Za-z0-9_]*)} Ada
  32. newPref v wordBreakPreface {[^a-zA-Z0-9_]} Ada
  33.  
  34. # Don't get used!
  35. #set adaCommentRegexp    {/\*(([^*]/)|[^*]|\r)*\*/}
  36. #set adaPreRegexp        {^\#[\t ]*[a-z]*}
  37. set adaKeyWords        {
  38.     abort abs accept access all and array at begin body case constant
  39.     declare delay delta digits do else elsif end entry exception exit
  40.     for function generic goto others if in is limited loop mod new not
  41.     null of or subtype out package pragma private procedure raise range
  42.     record rem renames return reverse select separate task terminate
  43.     then type use when while with xor = /=  := > < abstract aliased 
  44.     protected requeue tagged until
  45. }
  46. regModeKeywords -e {--} -c magenta -k blue Ada $adaKeyWords -i ")" -i "(" -i ":" -i ";" -i "," -i "." -I blue
  47. unset adaKeyWords
  48.  
  49. proc dummyAda {} {}
  50.  
  51. #===============================================================================
  52. # From Tom Konantz
  53. #===============================================================================
  54.  
  55. Bind f9 Ada::otherPart Ada
  56.  
  57. proc Ada::MarkFile {} {
  58.     global AdamodeVars
  59.     set pos [minPos]
  60.     
  61.     while {![catch {search -s -f 1 -r 1 -m 0 -i 1 $AdamodeVars(funcExpr) $pos} res]} {
  62.     set start [lindex $res 0]
  63.     set end [pos::math [lindex $res 1] + 1]
  64.     set text [getText $start $end]
  65.     
  66.     if {[regexp -nocase -indices {(procedure|function)[ \t]+([a-zA-Z0-9_]+)} $text dummy dummy0 pname]} {
  67.         set    i1 [expr [lindex $pname    0] + $start]
  68.         set    i2 [expr [lindex $pname 1] + $start + 1]
  69.         set    word [getText $i1 $i2]
  70.         set    tmp [concat $i1 $i2]
  71.         
  72.         if {[info exists cnts($word)]} {
  73.         # This section handles duplicate. i.e., overloaded names
  74.         set cnts($word) [expr $cnts($word) + 1]
  75.         set ol_word [ join [concat $word "#" $cnts($word)] ""]
  76.         set inds($ol_word) $tmp
  77.         } else {
  78.         set cnts($word) 1
  79.         set inds($word) $tmp
  80.         }
  81.     }
  82.     
  83.     
  84.     set pos $end
  85.     }
  86.     if {[info exists inds]} {
  87.     foreach f [lsort -ignore [array names inds]] {
  88.         set res $inds($f)
  89.         setNamedMark $f [lineStart [lindex $res 0]] [lindex $res 0] [lindex $res 1]
  90.     }
  91.     }
  92. }
  93.  
  94. # the following will switch between the Ada spec & body,
  95. # assuming they're in the same directory
  96. # and use either GNAT or VAX Ada naming conventions.
  97. # other conventions can be supported fairly easily.
  98. proc Ada::otherPart {} {
  99.     set curname [win::Current]
  100.     if {[regsub  "(.*)\.ads" $curname {\1.adb} tgtname]}  {
  101.     file::openQuietly $tgtname
  102.     } elseif  {[regsub  "(.*)\.adb" $curname {\1.ads} tgtname]}  {
  103.     file::openQuietly $tgtname
  104.     # Next clause must precede the one after it!
  105.     } elseif  {[regsub  {(.*)_\.a$} $curname {\1.a} tgtname]}  {
  106.     file::openQuietly $tgtname
  107.     } elseif  {[regsub  {(.*)\.a$} $curname {\1_.a} tgtname]}  {
  108.     file::openQuietly $tgtname
  109.     } else {
  110.     error "NoMatch"
  111.     }
  112. }
  113.  
  114.  
  115.